#define _CRT_SECURE_NO_WARNINGS 1

#include"My_string.h"


void string_test1()
{
	bit::string s1 = "abc";
	bit::string s2;
	bit::string s3 = s1;
	cout << s1.c_str() << endl;
	cout << s3.c_str() << endl;
	s2 = s1;
	cout << s2.c_str() << endl;
	s2 = s2;
	cout << s2.c_str() << endl;
}

void string_test2()
{
	const bit::string s1 = "abcdefg";
	for (size_t i = 0; i < s1.size(); i++)
	{
		cout << s1[i] << ' ';
	}
	cout << endl;
	//s1[s1.size()];
	//for (size_t i = 0; i < s1.size(); i++)
	//{
	//	s1[i]++;
	//	cout << s1[i] << ' ';
	//}

}

void string_test3()
{
	bit::string s2 = "abcdefg";
	for (auto e : s2)
	{
		e++;
		cout << e << ' ';
	}
	cout << endl;
	cout << s2.c_str() << endl;
	bit::iterator it1 = s2.begin();
	for (; it1 < s2.end(); it1++)
	{
		cout << *it1 << ' ';
	}
	cout << endl;
	it1 = s2.begin();
	for (; it1 < s2.end(); it1++)
	{
		(*it1)++;
		cout << *it1 << ' ';
	}
	cout << endl;
	cout << s2.c_str() << endl;

}

void string_test4()
{
	const bit::string s2 = "abcdefg";
	bit::const_iterator it1 = s2.begin();
	for (; it1 < s2.end(); it1++)
	{
		cout << *it1 << ' ';
	}
	cout << endl;
	it1 = s2.begin();
	//for (; it1 < s2.end(); it1++)
	//{
	//	(*it1)++;
	//	cout << *it1 << ' ';
	//}
	//cout << endl;
	//cout << s2.c_str() << endl;
}

void string_test5()
{
	bit::string s2;
	cout << "capacity: " << s2.capacity() << endl;
	cout << "size: " << s2.size() << endl;
	s2.push_back('*');
	s2.push_back('*');
	s2.push_back('*');
	cout << s2.c_str() << endl;
	cout << "capacity: " << s2.capacity() << endl;
	cout << "size: " << s2.size() << endl;
	s2.reserve(50);
	cout << "capacity: " << s2.capacity() << endl;
	s2.reserve(20);
	cout << "capacity: " << s2.capacity() << endl;

}

void string_test6()
{
	bit::string s2 = "abcdefg";
	s2.append("11111");
	cout << s2.c_str() << endl;
	cout << "capacity: " << s2.capacity() << endl;
	cout << "size: " << s2.size() << endl;
}

void string_test7()
{
	bit::string s2("abcdef");
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;
	///////////////////////////////
	//s2.insert(0,'*');
	//cout << s2.c_str() << endl;
	//cout << s2.size() << endl;
	//cout << s2.capacity() << endl;
	//////////////////////////////
	s2.insert(0, "******", 0, 3);
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;
	//bit::string s1("))))");
	/////////////////////////////////
	s2.insert(3, "!!!!");
	cout << s2.c_str() << endl;	
	s2.insert(s2.size(), "&&&&", 0, 3);
	cout << s2.c_str() << endl;
	/////////////////////////////////
	//s2.insert(0, s1);
	//cout << s2.c_str() << endl;	
	//s1 = "%%%%%";
	//s2.insert(s2.size(), s1, 0, 3);
	//cout << s2.c_str() << endl;
}

void string_test8()
{
	bit::string s2;
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;
	s2.insert(0, 'a');
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;
	s2.insert(0, '*');
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;
}

void string_test9()
{
	bit::string s1("1234567890");
	cout << s1.c_str() << endl;
	s1.erase(3);
	cout << s1.c_str() << endl;
	s1 = "1234567890";
	cout << s1.c_str() << endl;
	s1.erase(4,3);
	cout << s1.c_str() << endl;
}

void string_test10()
{
	bit::string s1("test.cpp.zip");
	size_t i = s1.find(".");
	cout << &s1[i] << endl;
	i = s1.find(".",i + 1);
	cout << &s1[i] << endl;
	i = s1.find(".cpp");
	cout << &s1[i] << endl;
	i = s1.find("",s1.size());
	cout << &s1[i] << endl;
}

void string_test11()
{
	bit::string s1("test.cpp.zip");
	size_t i = s1.find('.');
	cout << &s1[i] << endl;
	i = s1.find('.', i + 1);
	cout << &s1[i] << endl;
	i = s1.find(".cpp");
	cout << &s1[i] << endl;
	i = s1.find(' ', s1.size());
	cout << &s1[i] << endl;
}

void string_test12()
{
	bit::string s1("abcd");
	bit::string s2("1234");
	s2 += 'a';
	s1 += "11111";
	swap(s1, s2);
	cout << s1.c_str() << endl;
	cout << s1.size() << endl;
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;

}

void string_test13()
{
	bit::string s1("abcdefg");
	bit::string s2 = s1.substr(3);
	cout << s2.c_str() << endl;
}

void string_test14()
{
	bit::string s1("abcdefg");
	bit::string s2 = s1.substr(0,5);
	cout << (s1 > s2) << endl;
	cout << (s1 < s2) << endl;
	cout << (s1 >= s2) << endl;
	cout << (s1 <= s2) << endl;
	cout << (s1 == s2) << endl;
	cout << (s1 != s2) << endl;
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
	s1.clear();
	cout << s1.c_str() << endl;
	cout << s1.size() << endl;
	s1.clear();
}

void string_test15()
{
	bit::string s1("abcdefg");
	bit::string s2("abcdefg");
	cin >> s1 >> s2;
	cout << s1 << endl;
	cout << s1.size() << endl;
	cout << s2 << endl;
	cout << s2.size() << endl;
}

int main()
{
	string_test15();
	return 0;
}